package com.sgb.kjwl.view.widget.pick;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.PickDetialListViewRuleBinding;
import com.sgb.kjwl.model.entity.pick.TenderDictEntity3;
import com.sgb.kjwl.view.ui.adapter.pick.PickDetailRequireAdapter;

import java.util.List;

/**
 * Description:
 * Author zhengkewen
 * Time 2018/8/20
 */
public class PickDetailRuleListView extends LinearLayout {

    protected Context mContext;
    protected PickDetialListViewRuleBinding viewBinding;
    private PickDetailRequireAdapter adapter;

    public PickDetailRuleListView(Context context) {
        this(context, null);
    }

    public PickDetailRuleListView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public PickDetailRuleListView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        this(context, attrs, defStyleAttr, 0);
    }

    public PickDetailRuleListView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr);
        this.mContext = context;
        initView();
    }

    private void initView() {
        viewBinding = DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.pick_detial_list_view_rule, this, true);
        if (adapter == null) {
            adapter = new PickDetailRequireAdapter(mContext, null);
        }
        LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
        viewBinding.pickRecycler.setLayoutManager(layoutManager);
        viewBinding.pickRecycler.setAdapter(adapter);
        viewBinding.pickRecycler.setLoadingMoreEnabled(false);
        viewBinding.pickRecycler.setPullRefreshEnabled(false);
    }

    public void setRecyclerData(List<TenderDictEntity3> tenderDictEntity3List) {
        adapter.setDatas(tenderDictEntity3List);
    }
}
